﻿using System;
using System.Runtime.Serialization;
using LiSA_Server.Base.AbstractContracts;
using LiSA_Server.Base.Factories;
using LiSA_Service.Users.Actioners;

namespace LiSA_Service.Users.Dto.Queries
{
    [DataContract]
    public class UserInfoQuery : Query
    {
        [DataMember]
        public Guid ID { get; set; }

        [DataMember]
        public string UserName { get; set; }

        public override QueryResult Execute()
        {
            if (this.UserName.Length > 2)
            {
                return new UserInfoQueryResult
                {
                    User = ActionerFactory.Instance.Get<UserActioner>().GetUserByUserName(UserName)
                };
            }

            return new UserInfoQueryResult
            {
                User = ActionerFactory.Instance.Get<UserActioner>().GetUserByID(ID)
            };
        }
    }
}